<?php $this->headScript()->appendFile($this->JS_PATH . 'role.js'); ?>

<?php
echo $this->flashmessages();
?>
<div id="role-listing"></div>
<div class="container-fluid">
    <div id="pad-wrapper" class="form-page">
        <div class="row-fluid form-wrapper">
            <div class="span column">
                <?php if ($this->succesMessage != ''): ?>
                    <div class="alert alert-success">
                        <i class="icon-ok-sign"></i> <?php echo $this->succesMessage; ?>
                    </div>
                <?php endif; ?>

                <?php if (count($this->errorMessageArray) > 0): ?>
                    <div class="alert alert-error">
                        <?php foreach ($this->errorMessageArray as $erroValue): ?>
                            <div class="text-left">
                                <i class="icon-remove-sign"></i>
                                <?php echo $erroValue; ?>
                            </div>
                        <?php endforeach; ?>
                    </div>
                <?php endif; ?>
                 <h3><?php echo $this->translate("role_management"); ?></h3>
                 <br/>
             
                <form role="form"  id="role-form" name="role-form"  enctype="multipart/form-data"  action="" method="post">
                    <div class="role">
                        <div class="role_main"> 
                            <?php if ($this->user_roletype == 'SuperContractor'){ ?>
                                <div class="role_frm_type">
                                    <label><?php echo $this->translate("role_frm_constractor_name"); ?><span class="error-star">*</span>:</label>
                                    <div class="ui-select">
                                        <?php echo $this->form->role_contractor; ?>
                                    </div>
                                </div> 
                            <?php }else if ($this->user_roletype == 'SuperCustomer'){ ?>
                                <div class="role_frm_type">
                                    <label><?php echo $this->translate("role_frm_customer_name"); ?><span class="error-star">*</span>:</label>
                                    <div class="ui-select">
                                        <?php echo $this->form->role_customer; ?>
                                    </div>
                                </div> 
                            <?php }else { ?>
                                <div class="role_frm_type">
                                    <label><?php echo $this->translate("role_frm_admin_from_name"); ?><span class="error-star">*</span>:</label>
                                    <div class="ui-select">
                                        <?php echo $this->form->role_type; ?>
                                    </div>
                                </div>
                            <?php } ?>


                            <div class="admin_company_list">
                                <?php echo $this->listString; ?>
                            </div>
                        </div>
                        
                            <div class="role_allchk">
                            <input id="allcheckbox" type="checkbox" />
                            <label for="allcheckbox" class="select_unselect">
                                <?php echo $this->translate('select/unselect'); ?>
                            </label> 
                            </div>
                            <?php
                          
                            for ($i = 0; $i < count($this->module_data); $i++):
                                ?>
                                <div class="cls_module">
                                    <div class="cls_module_name">
                                        <?php
                                        echo ucfirst($this->translate($this->module_data[$i]['module_name']));
                                        ?>
                                    </div>
                                    <?php for ($j = 0; $j < count($this->module_data[$i]['action']); $j++): ?>
                                        <div class="cls_module_action">
                                            <input type="checkbox"  class="chk_cls" <?php if ($this->module_data[$i]['action'][$j]['checkbox_checked'] == 'true'): ?>
                                                       checked="checked" <?php endif; ?> name="role_data[]" 
                                                       id="<?php echo $this->module_data[$i]['controller_name'] . "_" . ucfirst($this->module_data[$i]['action'][$j]['chkbox_value']); ?>" 
                                                   value="<?php echo $this->module_data[$i]['controller_name'] . "_" . $this->module_data[$i]['action'][$j]['chkbox_value']; ?>" />
                                            <label for="<?php echo $this->module_data[$i]['controller_name'] . "_" . ucfirst($this->module_data[$i]['action'][$j]['chkbox_value']); ?>">
                                                <?php echo $this->translate($this->module_data[$i]['action'][$j]['name']); ?></label>
                                        </div>
                                        <?php
                                    endfor;
                                    ?>
                                </div>
                                <?php
                            endfor;
                            ?>
                        <br>

                        <div class="field-box">
                            <?php echo $this->form->Save; ?>
                            <?php echo $this->form->Reset; ?> 
                        </div>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
